#ifndef GENERATORWIDGET_H
#define GENERATORWIDGET_H

#include <QWidget>
#include "generatorinterface.h"
#include "generator_global.h"
class GeneratorObject;

namespace Ui {
class GeneratorWidget;
}

class GeneratorWidget : public QWidget, public GeneratorInterface
{
    Q_OBJECT
    Q_PLUGIN_METADATA(IID GeneratorPlugin_iid)
    Q_INTERFACES(GeneratorInterface)
public:
    explicit GeneratorWidget(QWidget *parent = 0);
    ~GeneratorWidget();

signals:
    void openSerialPort();

public:
    QObject *getObject() { return this; }
    void setGeneratorHook(GeneratorProc proc, void *userData) { m_proc = proc, m_userData = userData; }
    void setDoseValues(const double &kv, const double &ma, const double &ms, const double &mx);
    void getDoseValues(double &kv, double &ma, double &ms, double &mx) const;

private slots:
    void onDeviceStatus(GeneratorState state, const QString &msg);
    void onSaveValues();
    void onMsMode(bool checked);
    void onMxMode(bool checked);

private:
    void init();

    Ui::GeneratorWidget *ui;
    GeneratorObject *g;
    QThread *t;
    GeneratorProc m_proc;
    void *m_userData;
};

#endif // GENERATORWIDGET_H
